package servlet;

import bao.CartDao;
import model.Cart;
import service.CartService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class UpdateCartByName_Servlet extends HttpServlet {
    public UpdateCartByName_Servlet() {
        super();
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
                        req.setCharacterEncoding("utf-8");
                        resp.setCharacterEncoding("utf-8");
                        String name = req.getParameter("bk_name");
                        String cartNum = req.getParameter("bk_cartNum");
                        String cartNum_selected = req.getParameter("bk_cartNum_selected");
                        String price = req.getParameter("c_price_selected");
                        Cart cart = new Cart(cartNum,cartNum_selected,price,name);
                        CartDao cartDao = new CartDao();
                        cartDao.UpdateCartByName(cart,name);
                        resp.sendRedirect("QueryCart");

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
